home *** CD-ROM | disk | FTP | other *** search
- Path: gail.ripco.com!mambuhl
- From: mambuhl@ripco.com (Martin Ambuhl)
- Newsgroups: comp.lang.c
- Subject: qsort with large files
- Date: 5 Feb 1996 19:33:51 GMT
- Organization: Ripco Communications, Inc.
- Message-ID: <4f5m2v$8at@gail.ripco.com>
- NNTP-Posting-Host: golden.ripco.com
-
- Claude Leyo <leyo@mail.atlantic-line.fr>
- in <3113080C.349E@mail.atlantic-line.fr> asks:
-
- >I don't succeed trying to sort a large array of names in a structure
- >when the array is >64K. Is there a limitation of qsort() ? Thanks for
- >help.
-
- Some side issues:
- 1)
- Your function
-
- >int sort_function( name_list huge *p1, name_list huge *p2)
- >{ return strcmp((( struct name_list *)p1)->name,
- > (( struct name_list *)p2)->name);
- >}
-
- is used as the comparison function in the call to qsort. The comparison
- function takes two arguments of type "const void *". There is no reason
- to suppose sort_function will perform as you expect. Try something like:
-
- #define huge /* necessary for my compiler - ignore */
- int sort_function(const void *v1, const void *v2)
- {
- const struct name_list huge *p1 = v1, *p2 = v2;
- return strcmp(p1->name, p2->name);
- }
-
- I hope the syntax of the non-C non-keyword `huge' corresponds to your
- implementation.
-
- 2) Since your program uses `struct name_list' and `name_list' as
- synonyms without a typedef, this is C++ code, not C code. If you
- want it to be "Safe C", always uses `struct name_list'. If it is
- meant to be C and not C++, a typedef will make the synonmy ok.
-
- 3) Since your code uses "//" EOL comments, it is C++ code, not C code.
- When you post to comp.lang.c, "//" comments are syntax errors. Use
- "/* ... */" comments here.
-
- /***********/
- Now to the question you ask...
-
- Since your program uses huge declarations and farcalloc() calls, it is
- probably written for a MSDOS compiler. Limitations of 64K on objects
- are a problem of your implementation. There is some discussion in the
- FAQ, but better to read your implementation documentation. Even better,
- use a 32-bit flat-memory model compiler.
-
- --
- * Martin Ambuhl net: mambuhl@ripco.com
- * Chicago, IL (USA)
-